#include<iostream>
using namespace std;
#include<string>
class Solution {
public:
    string minWindow(string s, string t) {
        int arr1[128] = { 0 }, arr2[128] = { 0 }, count = 0;
        int beginans = 0, beginlong = INT_MAX;
        for (auto& e : t)
            if (++arr2[e] == 1)
                ++count;
        for (int left = 0, right = 0; right < s.size(); ++right) {
            ++arr1[s[right]];
            if (arr1[s[right]] == arr2[s[right]])
                --count;
            while (arr1[s[left]] > arr2[s[left]])
                --arr1[s[left++]];
            if (count == 0 && right - left + 1 < beginlong) {
                beginlong = right - left + 1;
                beginans = left;
            }
        }
        if (beginlong != INT_MAX)
            return s.substr(beginans, beginlong);
        return "";
    }
};